int main(){ unsigned int random; random = rand(); // random value! printf("random=%d", random); return 0; }
random@pwnable:/tmp/own$ gcc random.c -o random random.c: In function ‘main’: random.c:5:11: warning: implicit declaration of function ‘rand’ [-Wimplicit-function-declaration] random = rand(); // random value! ^ random@pwnable:/tmp/own$ ./random random=1804289383
接下来就是计算key值:
1 2
key ^ random == 0xdeadbeef key = random ^ 0xdeadbeef = 1804289383 ^ 0x0xdeadbeef = 0xB526FB88 = 3039230856
1 2 3 4 5
random@pwnable:~$ ./random 3039230856 Good! Mommy, I thought libc random is unpredictable... random@pwnable:~$